//
//  BaseReadImageView.m
//  MapleLeaf
//
//  Created by WangZe on 15/12/8.
//  Copyright © 2015年 AntennaBabyTeam. All rights reserved.
//

#import "BaseReadImageView.h"

@implementation BaseReadImageView
//当有一个或多个手指触摸事件在当前视图或window窗体中响应
- (instancetype)init
{
    self = [super init];
    if (self) {
        [self addGesture];
    }
    return self;
}
- (void)addGesture
{
    UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPressAction:)];
    [self addGestureRecognizer:longPress];
}

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    [super touchesBegan:touches withEvent:event];

    NSLog(@"触摸开始");
    NSSet *allTouches = [event allTouches];    //返回与当前接收者有关的所有的触摸对象
    UITouch *touch = [allTouches anyObject];   //视图中的所有对象
    CGPoint point = [touch locationInView:[touch view]]; //返回触摸点在视图中的当前坐标
    NSInteger x = point.x;
    NSInteger y = point.y;
    
    [self.delegate TouchsBegintouchPointX:x WithTouchPointY:y];
}


#warning 在继承和使用父类方法的时候,一般会先用super去调用父类相应的方法,目的是为了保证方法的原功能不变,在此基础上再添加我们自己的功能

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
    [super touchesMoved:touches withEvent:event];
    NSLog(@"触摸移动");
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
    [super touchesEnded:touches withEvent:event];
    NSLog(@"触摸结束");
}
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
{
    [super touchesCancelled:touches withEvent:event];
    NSLog(@"触摸取消");
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
